package com.example.service.impl;

import com.example.common.PageResult;
import com.example.dto.LifePageDto;
import com.example.entity.LifePlace;
import com.example.mapper.LifePlaceMapper;
import com.example.service.LifePlaceService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LifePlaceServiceImpl implements LifePlaceService {
    @Autowired
    private LifePlaceMapper lifePlaceMapper;

    @Override
    public PageResult page(LifePageDto lifePageDto) {
        PageHelper.startPage(lifePageDto.getPageNum(), lifePageDto.getPageSize());
        Page<LifePlace> page =  lifePlaceMapper.findByDno(lifePageDto);
        return new PageResult(page.getTotal(),page.getResult());
    }

    @Override
    public void add(LifePlace lifePlace) {
        lifePlaceMapper.add(lifePlace);
    }

    @Override
    public void deleteByDno(String dno) {
        lifePlaceMapper.deleteByDno(dno);
    }

    @Override
    public void update(LifePlace lifePlace) {
        lifePlaceMapper.update(lifePlace);
    }
}
